home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ARSRC21.ZIP / AR256SPR.CPP < prev    next >
C/C++ Source or Header  |  1995-05-23  |  3KB  |  137 lines

  1. #include <graphics.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include "ar256h.cpp"
  5. #include "ar256def.h"
  6. #include "ar256ex.h"
  7.  
  8. // this file has the functions that glide the monster tiles about.
  9. extern int SLIDE;
  10.  
  11. drawjustland(char,char,char,char);
  12. spritepath(int,int,int,int,unsigned char *);
  13. drawjustframe(int,int,unsigned char *);
  14.  
  15.  
  16.  
  17.  
  18. drawjustland(char tilex,char tiley,char centrex,char centrey)
  19.     {
  20.     if(!SLIDE)return(0);
  21.     int i,nx,ny,px,py;char mtile; //nx,ny are toplefts pix
  22.  
  23.     nx=((signed char)tilex-centrex+7)*32;ny=((signed char)tiley-centrey+7)*32;
  24.  
  25.     if((tilex>=width)||(tiley>=height)||(tilex<0)||(tiley<0))//if off map dont draw. You'd think it'd wrap and be always false but it DOESNT.
  26.         {
  27.         setfillstyle(1,0xd3);
  28.         bar(nx,ny,nx+31,ny+31);
  29.         return(1);
  30.         }
  31.     setfillstyle(1,2);
  32.  
  33.     bar(nx,ny,nx+31,ny+31);
  34.  
  35.     if(sq[tilex][tiley].land)
  36.         {
  37.  
  38.  
  39.         if(sq[tilex][tiley].land>9)
  40.             {
  41.             for (i=0;i<0x400;++i)   //draw ballz
  42.                 {
  43.                 px=nx+(i % 32);py=ny+(i / 32);
  44.                 if (ball[sq[tilex][tiley].land-10][i] != 0xff) putpixel(px,py,ball[sq[tilex][tiley].land-10][i]);
  45.                 if (ball[sq[tilex][tiley].land-10][i] == 247)  putpixel(px,py,247+sq[tilex][tiley].whose);
  46.                 }
  47.  
  48.             }
  49.  
  50.         else
  51.             {
  52.             for (i=0;i<0x400;++i)   //draw trees craters etc etc
  53.                 {
  54.                 px=nx+(i % 32);py=ny+(i / 32);
  55.                 if (terrt[sq[tilex][tiley].land-1][i] != 0xff) putpixel(px,py,terrt[sq[tilex][tiley].land-1][i]);
  56.                 }
  57.             }
  58.  
  59.         }
  60.  
  61.     return(0);
  62.  
  63.     }
  64.  
  65.  
  66. spritepath(int ax,int ay,int bx, int by, unsigned char *thistile)
  67.  
  68.     {
  69.     if(!SLIDE)return(0);
  70.     void *background=malloc(0x440);//64 extra bytes in case.
  71.     signed int xdiff,ydiff;
  72.     float xstep,ystep,x,y;
  73.     int i;
  74.     x=ax;y=ay;
  75.     xdiff=bx-ax;
  76.     ydiff=by-ay;
  77.     xstep=(float)xdiff/16;
  78.     ystep=(float)ydiff/16;
  79.  
  80.     getimage(x,y,x+32,y+32,background);
  81.  
  82.  
  83.     for(i=0;i<16;++i)
  84.         {
  85.  
  86.  
  87.         drawjustframe(x,y,thistile);
  88.         if((x<16)||(x>464)||(y<16)||(y>464))continue;// I dont see why it should ever go off the map bu just in case...
  89.         delay(17);
  90.         putimage(x,y,background,0);
  91.         getimage(x+xstep,y+ystep,x+xstep+32,y+ystep+32,background);
  92.         x+=xstep;y+=ystep;
  93.         }
  94.  
  95.     free(background);
  96. }
  97.  
  98. drawjustframe(int x, int y, unsigned char *thistile)
  99.     {
  100.     int i,px,py;
  101.  
  102.     if(!(curpla%2))    //flip if even player.
  103.         {
  104.  
  105.         for(i=0;i<0x400;++i)
  106.             {
  107.             px=x+(i%32);py=y+(i/32);
  108.             if(thistile[i]<254)putpixel(px,py,thistile[i]);
  109.             if(thistile[i]==254)putpixel(px,py,pcol[curpla]);
  110.             }
  111.         }
  112.     else
  113.         {
  114.         for(i=0;i<0x400;++i)
  115.             {
  116.             px=x+32-(i%32);py=y+(i/32);
  117.             if(thistile[i]<254)putpixel(px,py,thistile[i]);
  118.             if(thistile[i]==254)putpixel(px,py,pcol[curpla]);
  119.             }
  120.         }
  121. }
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.